<%@page import="java.util.List"%>
<%@ page language="java" 
    import ="com.jju.A1541.model.*"
    import ="com.jju.A1541.dao.*"
    contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%
       //1.获得表单的输入
       String username = request.getParameter("username");
       String tel  = request.getParameter("tel");
       String password = request.getParameter("password");
       String bjzz = request.getParameter("bjzz");
       String checkbox = request.getParameter("checkbox");
       User username1 = UserDAO.zcyz(username);
       User tel1 = UserDAO.zcyz1(tel);
       User username2 = UserDAO.zcyz2(username);
       User tel2 = UserDAO.zcyz3(tel);
       if(bjzz==null){
       //2.创建用户实体类User对象并进行赋值
         User  obj = new User();
          obj.setUsername(username);
          obj.setPassword(password);
          obj.setTel(tel);
        	if(username.length()==11  && tel.length()==11 && username1!=null && tel1==null && checkbox!=null){
        			//3.调用UserDAO完成实体对象的持久化--保存到数据库表中
        			int n = UserDAO.add(obj);
        			//4..对结果的处理
        			 if(n>0){
        				 out.print("<script>alert('注册成功！请您登录！'); window.location='login.jsp' </script>");
        			 }
        	}else{
        		out.print("<script>alert('注册失败，信息有误！'); window.location='signup.jsp' </script>");
            }
       }
       else{
    	   User  obj = new 	User();
           obj.setUsername(username);
           obj.setPassword(password);
           obj.setTel(tel);
         	if(tel.length()==11 && username2==null && tel2==null && checkbox!=null ){
         			//3.调用UserDAO完成实体对象的持久化--保存到数据库表中
         			int n = UserDAO.add1(obj);
         			//4..对结果的处理
         			 if(n>0){
         				out.print("<script>alert('注册成功！请您登录！'); window.location='login.jsp' </script>");     
         				}
         	}else{
         		out.print("<script>alert('注册失败，信息有误！'); window.location='signup.jsp' </script>");
             }
       }
        
       %>